package version1;

import java.util.ArrayList;
import java.util.List;

public class Demo1 {

    public static void main(String[] args) {

        List list = new ArrayList();
        list.add("apple");
        list.add(new Integer(10));

        Object o = list.get(0);
        Object o1 = list.get(1);
        System.out.println(o);
        System.out.println(o1);

        String s = (String) list.get(0);
        String s1 = (String) list.get(1); //Exception in thread "main" java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
        System.out.println(s);
        System.out.println(s1);
    }
}
